import React, { useRef } from 'react'
import Hello from './components/Hello'

export default function LayOut () {
  const pEle = useRef(null)
  const hello = useRef(null)
  function getP () {
    console.log('pEle', pEle.current)
  }
  function gethello () {
    console.log('gethello', hello.current)
    hello.current.add
  }
  return (
    <div>
      元素获取 <hr />
      <button onClick={getP}>获取p</button>
      <p ref={pEle}></p>
      组件获取
      <button onClick={gethello}>获取组件</button>
      {/* ref不能绑定函数组件 */}
      {/* <button onClick={add}>+</button> */}
      <Hello ref={hello} />

    </div>
  )
}

